//
//  SettingTableViewController.m
//  LvZhi201805
//
//  Created by 付明玉 on 2018/5/17.
//  Copyright © 2018年 付明玉. All rights reserved.
//

#import "SettingTableViewController.h"
#import "ModificationViewController.h"

@interface SettingTableViewController ()

@end

@implementation SettingTableViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    self.view.backgroundColor = COLOR(251, 251, 251, 1);
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    if (section == 0) {
        
        return 1;
        
    } else {
        
        return 4;
    }
    
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
    
    if (cell == nil) {
        
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"Cell"];
        
        if (indexPath.section == 0) {
            
            //标签
            cell.textLabel.text = @"头像";
            
            //图片
            UIImageView *headerImage = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 86, 14, 63, 63)];
            headerImage.image = [UIImage imageNamed:@"图层34"];
            [cell addSubview:headerImage];
            
        } else if (indexPath.section == 1) {
            
            if (indexPath.row == 0) {
                
                cell.textLabel.text = @"账户名称";
                cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
                
            } else if (indexPath.row == 1) {
                
                cell.textLabel.text = @"修改密码";
                cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
                
            } else if (indexPath.row == 2) {
                
                cell.textLabel.text = @"修改手机号";
                cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
                
            } else {
                
                cell.textLabel.text = @"修改邮箱";
                cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            }
        }
    }
    
    cell.textLabel.textColor = COLOR(102, 102, 102, 1);
    cell.textLabel.font = [UIFont systemFontOfSize:12];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (indexPath.section == 0) {
        
        return 91;
        
    } else {
        
        return 50;
    }
    
    return 0;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 6)];
    view.backgroundColor = COLOR(251, 251, 251, 1);
    
    return view;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    
    if (section == 1) {
        
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 6)];
        view.backgroundColor = COLOR(251, 251, 251, 1);
        
        return view;
    } else {
        
        return nil;
    }
    
    return nil;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    
    if (section == 1) {
        return 10;
    }
    
    return 0;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    
    return 6;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (indexPath.section == 1) {
        
        if (indexPath.row == 1) {
            
            ModificationViewController *modificationViewController = [[ModificationViewController alloc] init];
            [self.navigationController pushViewController:modificationViewController animated:YES];
        }
    }
}

- (void)viewWillAppear:(BOOL)animated
{
    
    [super viewWillAppear:animated];
    
    //显示导航栏
    self.navigationController.navigationBarHidden = NO;
    
    //标题
    self.navigationItem.title = @"账户设置";
    
    //背景色
    [self.navigationController.navigationBar setBarTintColor:COLOR(18, 79, 151, 1)];
    
    //字体颜色
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    
    //设置返回按钮颜色
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    
    //字体
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, [UIFont fontWithName:@"AmericanTypewriter-Bold" size:18], NSFontAttributeName, nil]];
}

@end
